package com.qijian.maindata.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qijian.maindata.domain.ProjectBeiku;
import com.qijian.maindata.domain.query.ProjectBeikuQuery;
import com.qijian.maindata.domain.vo.ProjectBeikuListVo;
import com.qijian.maindata.domain.vo.ProjectBeikuVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 开工令备库项目Mapper接口
 *
 * @author qijian
 * @date 2023-12-25
 */
public interface ProjectBeikuMapper extends BaseMapper<ProjectBeiku> {

    @Select("select count(0) from main_project_beiku WHERE create_time >= CURRENT_DATE ")
    int countCurrentDateWithDel();

    Page<ProjectBeikuListVo> pageProjectList(Page<ProjectBeikuListVo> page, @Param(Constants.WRAPPER) Wrapper<ProjectBeikuQuery> queryWrapper);

    @Delete("delete from main_project_beiku where bk_project_id = #{bkProjectId} and version != #{version}")
    void removeByVersion(@Param("version") String version, @Param("bkProjectId") Long bkProjectId);

    ProjectBeikuListVo getByBKProjectId(@Param("bkProjectId") Long bkProjectId);

    List<ProjectBeikuVo> getListByBKProjectIds( @Param("ids")  List<Long> bkProjectIds);
}
